package com.yao.ecommerce.converter;

import com.yao.ecommerce.constant.BrandCategory;

import javax.persistence.AttributeConverter;

/**
 * <h1>品牌类别转换器</h1>
 */
public class BrandCategoryConverter implements AttributeConverter<BrandCategory,String> {

    @Override
    public String convertToDatabaseColumn(BrandCategory brandCategory) {

        return brandCategory.getCode();
    }

    @Override
    public BrandCategory convertToEntityAttribute(String code) {

        return BrandCategory.of(code);
    }
}
